package com.yinet.yyqh.service.impl;

import com.yinet.common.core.domain.Ztree;
import com.yinet.common.core.text.Convert;
import com.yinet.generator.domain.User;
import com.yinet.generator.domain.YinetNotPass;
import com.yinet.generator.domain.YinetVideo;
import com.yinet.generator.domain.YinetYctk;
import com.yinet.wsyy.mapper.YctkMapper;
import com.yinet.yyqh.service.Yctkervice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 网上预约列表Service业务层处理
 *
 * @author yinet
 * @date 2019-09-02
 */
@Service
public class YctkServiceImpl implements Yctkervice {
    @Autowired
    private YctkMapper yctkMapper;

    //远程查看列表
    @Override
    public List<YinetYctk> selectYinetYctk(String isfinish,YinetYctk yctk,String loginName) {
        return yctkMapper.selectYinetYctk(Integer.parseInt(isfinish),yctk,loginName);
    }
    //id查询信息
    @Override
    public YinetYctk selectById(String id) {
        return yctkMapper.selectById(id);
    }
    //添加踏勘信息
    @Override
    public int insertYctk(YinetYctk yinetYctk) {
        User user=yctkMapper.selectUserName(yinetYctk.getTk_realname());
        yinetYctk.setTk_username(user.getLogin_name());
        return yctkMapper.insertYctk(yinetYctk);
    }
    //修改远程踏勘信息
    public int updateYctk(YinetYctk yctk){
        System.err.println(yctk);
        User user=yctkMapper.selectUserName(yctk.getTk_realname());
        yctk.setAdd_Time(yctkMapper.selectById(yctk.getId()+"").getAdd_Time());
        return yctkMapper.updateYctk(yctk);
    };
    //踏勘通过
    public int updateTaKanTG(String uuid){
        return yctkMapper.updateTaKanTG(uuid);
    };
    //踏勘不通过
    public int updateBTG(String uuid){
        return yctkMapper.updateBTG(uuid);
    };
    //添加不通过
    public int addNotPass(YinetNotPass pass){
        return yctkMapper.addNotPass(pass);
    };
    //查找人员
    public List<Ztree> selectUserName(){
        List<User>list = yctkMapper.selectPersonUserName();
        List<Ztree> ztrees = new ArrayList<Ztree>();
        for (User user : list){
            Ztree ztree = new Ztree();
            ztree.setId(Long.valueOf(user.getUser_id()));
            ztree.setpId(Long.valueOf(user.getUser_id()));
            ztree.setName(user.getUser_name());
            ztree.setTitle(user.getUser_name());
            ztrees.add(ztree);
        }
        return ztrees;
    };

    //添加视频
    public int insertVideo(YinetVideo video){
        return yctkMapper.insertVideo(video);
    };

    //删除踏勘
    public int deleteYctk(String ids){
        return yctkMapper.deleteYctk(Convert.toStrArray(ids));
    };
    //重置状态
    public int updateReset(String id){
        return yctkMapper.updateReset(id);
    };
    //查询踏勘地址
    public YinetYctk selectSite(String uuid){
        return yctkMapper.selectSite(uuid);
    };
    //查询当前id的账号isfinish信息
    public  List<YinetYctk>selectIsfinishCard(String id){
        return yctkMapper.selectIsfinishCard(id);
    };
    //修改uuid为正在踏勘中
    public int updateIsfinish(String uuid){
        return yctkMapper.updateIsfinish(uuid);
    };
}
